﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using DAO;
namespace BUS
{
    public class KhuyenMaiBUS
    {
        KhuyenMaiDAO kmdao = new KhuyenMaiDAO();
        public List<KhuyenMaiDTO> LayDanhSachKhuyenMai()
        {
            List<KhuyenMaiDTO> KQ = kmdao.LayDanhSachKhuyenMai();
            return KQ;
        }
        public List<KhuyenMaiDTO> LayDanhSachKhuyenMai(int MACTKM)
        {
            List<KhuyenMaiDTO> KQ = kmdao.LayDanhSachKhuyenMai(MACTKM);
            return KQ;
        }
        public int ThemKhuyenMai(KhuyenMaiDTO kmadto)
        {
            return kmdao.ThemKhuyenMai(kmadto);
        }
        public int CapNhatKhuyenMai(KhuyenMaiDTO kmadto)
        {
            return kmdao.CapNhatKhuyenMai(kmadto);
        }
        public int XoaKhuyenMai(int ma)
        {
            return kmdao.XoaKhuyenMai(ma);
        }
        public bool kiemtra(int ngay, int thang, int nam)
        {
            int[] songay = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
            if ((nam % 400 == 0) || (nam % 100 != 0 && nam % 4 == 0))
            {
                songay[2] = 29;
            }

            if (ngay <= songay[thang])
            {
                return true;
            }
            else
                return false;
        }
    }
}
